<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="header">
        <span>销售类别占比</span>
        <el-radio-group v-model="radio" size="mini">
          <el-radio-button label="全部渠道"></el-radio-button>
          <el-radio-button label="线上"></el-radio-button>
          <el-radio-button label="门店"></el-radio-button>
        </el-radio-group>
      </div>
      <div class="echarts" ref="pieCharts"></div>
    </el-card>
  </div>
</template>

<script>
import lineCharts from "@/views/dashboard/card/lineCharts";
import echarts from "echarts";
export default {
  components: {
    lineCharts,
  },
  data() {
    return {
      radio: "全部渠道",
    };
  },
  mounted() {
    let myCharts = echarts.init(this.$refs.pieCharts);
    myCharts.setOption({
      title: {
        text: "视频广告",
        subtext: "1048",
        left: "center",
        top: "center",
      },
      tooltip: {
        trigger: "item",
      },
      series: [
        {
          name: "Access From",
          type: "pie",
          radius: ["40%", "70%"],
          avoidLabelOverlap: false,
          label: {
            show: true,
            position: "outsize",
          },
          labelLine: {
            show: true,
          },
          data: [
            { value: 1048, name: "视频广告" },
            { value: 735, name: "联盟广告" },
            { value: 580, name: "邮件营销" },
            { value: 484, name: "直接访问" },
            { value: 300, name: "搜索引擎" },
          ],
        },
      ],
    });
    myCharts.on("mouseover", (params) => {
      let { name, value } = params.data;
      myCharts.setOption({
        title: {
          text: name,
          subtext: value,
        },
      });
    });
  },
};
</script>

<style scoped>
.header {
  display: flex;
  justify-content: space-between;
}
.echarts {
  width: 100%;
  height: 338px;
  text-align: center;
}
::v-deep .el-card__header {
  height: 55.52px;
}
::v-deep .el-card__body {
  height: 388.4px;
}
</style>
